import request from '@/utils/request'
import qs from 'qs'

export const getUsers = (params: any) =>
  request({
    url: '/users',
    method: 'get',
    params
  })

export const getUserInfo = (data: any) =>
  request({
    url: '/consumer/user/info',
    method: 'get',
    data
  })

export const getUserByName = (username: string) =>
  request({
    url: `/users/${username}`,
    method: 'get'
  })

export const updateUser = (username: string, data: any) =>
  request({
    url: `/users/${username}`,
    method: 'put',
    data
  })

export const deleteUser = (username: string) =>
  request({
    url: `/users/${username}`,
    method: 'delete'
  })

export const client32081 = () =>
  request({
    url: '/consumer/oauth/32081',
    method: 'get'
  })
export const login = (data: any) =>
  request({
    url: '/consumer/oauth/token',
    method: 'post',
    data: qs.stringify(data)
  })

export const logout = () =>
  request({
    url: '/users/logout',
    method: 'post'
  })

export const register = (data: any) =>
  request({
    url: '/users/register',
    method: 'post',
    data
  })

export const compayLs = (params: any) =>
  request({
    url: '/consumer/user/company-list',
    params
  })

export const saveCompany = (data: any) =>
  request({
    url: '/consumer/user/save-company',
    method: 'post',
    data
  })
export const destoryCompany = (data: any) =>
  request({
    url: '/consumer/user/destory-company',
    method: 'post',
    data
  })

export const sysPermission = (data: any) =>
  request({
    url: '/consumer/user/sys-permission',
    method: 'post',
    data
  })

export const savePermission = (data: any) =>
  request({
    url: '/consumer/user/save-permission',
    method: 'post',
    data
  })

export const destoryPermission = (data: any) =>
  request({
    url: '/consumer/user/destory-permission',
    method: 'post',
    data
  })

export const roleList = (data: any) =>
  request({
    url: '/consumer/user/role-list',
    method: 'post',
    data
  })

export const user2role = (data: any) =>
  request({
    url: '/consumer/user/user2role',
    method: 'post',
    data
  })

export const role2perm = (data: any) =>
  request({
    url: '/consumer/user/role2perm',
    method: 'post',
    data
  })

export const saveRole2permission = (data: any) =>
  request({
    url: '/consumer/user/save-role2permission',
    method: 'post',
    data
  })

export const destoryRoleById = (data: any) =>
  request({
    url: '/consumer/user/destoryRoleById',
    method: 'post',
    data
  })

export const users = (params: any) =>
  request({
    url: '/consumer/user/users',
    params
  })

export const saveUser = (data: any) =>
  request({
    url: '/consumer/user/save-user',
    method: 'post',
    data
  })

export const destoryUser = (data: any) =>
  request({
    url: '/consumer/user/destory-user',
    method: 'post',
    data
  })
export const repasswd = (data: any) =>
  request({
    url: '/consumer/user/repasswd',
    method: 'post',
    data: qs.stringify(data)
  })

export const repasswd4person = (data: any) =>
  request({
    url: '/consumer/user/repasswd4person',
    method: 'post',
    data: qs.stringify(data)
  })
